package com.brian.hystrix.web;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;

@SpringBootApplication
@ServletComponentScan
public class HelloWorldApplication {

	public static void main(String[] args) {
		SpringApplication.run(HelloWorldApplication.class,args);
	}

	@Bean
	public EmbeddedServletContainerCustomizer customize() {

		return new EmbeddedServletContainerCustomizer() {
			@Override
			public void customize(ConfigurableEmbeddedServletContainer container) {
				container.setSessionTimeout(10800);
				container.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, "/views/error/400.html"));
				container.addErrorPages(new ErrorPage(HttpStatus.UNAUTHORIZED,"/views/error/401.html"));
				container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/views/error/404.html"));
				container.addErrorPages(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/views/error/500.html"));

			}
		};
	}

}
